package com.ludaxu.google.holder;

import android.text.format.Formatter;
import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.ludaxu.google.R;
import com.ludaxu.google.domain.AppInfo;
import com.ludaxu.google.tools.UiUtils;

public class ListBaseHolder extends BaseHolder<AppInfo> {

	ImageView item_icon;
	TextView item_title, item_size, item_bottom;
	RatingBar item_rating;

	public void refreshView(AppInfo data) {
		this.item_title.setText(data.getName());
		this.item_size.setText(Formatter.formatFileSize(UiUtils.getContext(),
				data.getSize()));
		this.item_bottom.setText(data.getDes());
		this.item_rating.setRating(data.getStarts());// 设置RatingBar的值
		String iconUrl = data.getIconUrl();

		bitmapUtils.display(this.item_icon, "http://127.0.0.1:8090/image?name="
				+ iconUrl);
	}

	@Override
	public View initView() {
		View contentView = View.inflate(UiUtils.getContext(),
				R.layout.item_app, null);
		this.item_icon = (ImageView) contentView.findViewById(R.id.item_icon);
		this.item_title = (TextView) contentView.findViewById(R.id.item_title);
		this.item_size = (TextView) contentView.findViewById(R.id.item_size);

		this.item_bottom = (TextView) contentView
				.findViewById(R.id.item_bottom);
		this.item_rating = (RatingBar) contentView
				.findViewById(R.id.item_rating);
		return contentView;
	}

}
